<{include file="public/header.html"}>
<style type="text/css">
    .s2 td{
		border-bottom: solid 1px #E8E8E8;
		border-right: solid 1px #E8E8E8;
		text-align: center;
 	}
 	.s1 td{
		border-bottom: solid 1px #E8E8E8;
		border-right: solid 1px #E8E8E8;
		text-align: center;
 	}
 	.s11 td{
		border-bottom: solid 1px #A0A0A0;
		border-right: solid 1px #E8E8E8;
		text-align: center;
 	}
 	.s22 td{
		border-bottom: solid 1px #A0A0A0;
		border-right: solid 1px #E8E8E8;
		text-align: center;
 	}
 	.xinsu-buy-bgcolor3{
		border-right: solid 1px #E8E8E8;
		text-align: center;
 	}
 	.zls-stock-info{
		border:solid 1px #A0A0A0;
		border-collapse: separate;
 	}
</style>
		<script type="text/javascript" src="<{STATIC_SERVER}>/home/js/SuggestServer_3_0_16.js"></script>
		<div class="xinsu-right">
			<div class="xinsu-right-title" id="xinsu-zhishu"></div>
			<div class="xinsu-right-content xinsu-right-content-bg">	
				<div class="xinsu-buy-form">
					<div class="xinsu-buy-left zls-stock-info">
						<form action="" method="post">
							<table width="100%" >
								<tbody>
									<tr class="xinsu-row-title">
										<td colspan="2">股票买入</td>
									</tr>
									<tr class="xinsu-row-ls">
										<td height="38" align="right" width="120">可用额度：</td>
										<td><span class="xinsu-fontcolor-red">￥<{number_format($user.amount, 2)}></span></td>
									</tr>
									<tr class="xinsu-row-ls">
										<td align="right" width="120">证券代码：</td>
										<td class="xinsu-position">
											<input type="text" name="stock_code" id="stock_code"class="layui-input" placeholder="代码/名称/拼音" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{else}>onBlur="get_stock();"<{/if}> />
										</td>	
									</tr>
									<tr class="xinsu-row-ls">
										<td align="right" width="120">证券名称：</td>
										<td>
											<input type="text" name="stock_name" id="stock_name" class="layui-input xinsu-fontcolor-red" disabled>
										</td>	
									</tr>
									<tr class="xinsu-row-ls">
										<td align="right" width="120">当前价格：</td>
										<td>
											<input type="text" name="stock_price" id="stock_price" class="layui-input xinsu-fontcolor-green" readonly>
										</td>	
									</tr>
									<tr class="xinsu-row-ls">
										<td height="38" align="right" width="120">证券类型：</td>
										<td>
											<input type="radio" name="bull_type" value="1" title="融资" checked <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>/>
											<span class="xinsu-fontcolor-red">融资</span>
											<input type="radio" name="bull_type" value="2" title="融券" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>/>
											<span class="xinsu-fontcolor-green">融券</span>
										</td>	
									</tr>								
									<tr class="xinsu-row-ls">
										<td height="38" align="right" width="120">买入价格：</td>
										<td>
											<input type="radio" name="price_type" value="0" title="市价" checked <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>/>
											<span class="xinsu-fontcolor-green">市价</span>
											<input type="radio" name="price_type" value="1" title="委托价" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>/>
											<span class="xinsu-fontcolor-red">委托价</span>
										</td>	
									</tr>
									<tr class="xinsu-row-ls" style="display:none;" id="xinsu-price-type">
										<td align="right" width="120">委托价格：</td>
										<td>
											<input type="text" name="bull_price" class="layui-input xinsu-fontcolor-red" id="bull_price" placeholder="请输入委托价格">
										</td>	
									</tr>
									<tr class="xinsu-row-ls">
										<td align="right" width="120">可买股：</td>
										<td>
											<input type="text" name="num" id="num" class="layui-input" disabled>
											<button class="layui-btn xinsu-btn-buy" type="button" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{else}>onclick="bull_all()"<{/if}>>全部</button>
										</td>	
									</tr>
									<tr class="xinsu-row-ls">
										<td align="right" width="120">买入数量：</td>
										<td>
											<input type="text" name="bull_num" id="bull_num" class="layui-input" <{if $common_info.holiday == "休市" || $user.amount <= 0}>disabled<{/if}>>
											<font class="xinsu-fontcolor-grey">股</font>
										</td>	
									</tr>
									<tr class="xinsu-row-ls">
										<td align="right" width="120"></td>
										<td>
											<button class="layui-btn xinsu-btn-buy" type="submit">下单</button>
											<button class="layui-btn xinsu-btn-buy" type="reset">重填</button>
										</td>	
									</tr>
								</tbody>
							</table>
						</form>
					</div>
					<div class="xinsu-buy-right">
						<div class="xinsu-form">
							<table width="100%" class="zls-stock-info">
								<tbody id="xinsu-stock-info">
									<tr class="xinsu-buy-bgcolor1 s1">
										<td align="center">卖五</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-green">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor1 s1">
										<td align="center">卖四</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-green">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor1 s1">
										<td align="center">卖三</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-green">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor1 s1">
										<td align="center">卖二</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-green">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor1 s11">
										<td align="center">卖一</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-green">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor2 s2" >
										<td align="center">买一</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-red">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor2 s2" >
										<td align="center">买二</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-red">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor2 s2">
										<td align="center">买三</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-red">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor2 s2">
										<td align="center">买四</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-red">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor2 s22">
										<td align="center">买五</td>
										<td colspan="2" align="center" class="xinsu-fontcolor-red">--</td>
										<td>0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor3">
										<td align="center">现价：</td>
										<td class="xinsu-fontcolor-green">--</td>
										<td>昨收：</td>
										<td class="xinsu-fontcolor-red">0</td>
									</tr>
									<tr class="xinsu-buy-bgcolor3">
										<td align="center">最高价：</td>
										<td class="xinsu-fontcolor-red">0</td>
										<td>最低价：</td>
										<td class="xinsu-fontcolor-green">0</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
					<div class="xinsu-clear"></div>
				</div>
			</div>
		</div>
		<{if $common_info.holiday != "休市" || $user.amount <= 0}>
		<script>
			$(function(){
				//股票查询事件
				var suggestServer = new SuggestServer();
				suggestServer.bind({
					"input": "stock_code",
					"value": "@2@",
					"type": "",
					"max": 10,
					"width": 250,
					"head": ["选项", "代码", "中文名称"],
					"body": [-1, 2, 4],
					"fix": { "ie6" : [0, - 1], "ie7" : [0, - 1], "firefox" : [1, 1]},
					"callback": function(){
						stock = 0;
						get_stock();
					}
				});
			})
			var amount = "<{$user.amount}>";
			var stock = 0;
			
			//市价，委托价选择
			$("input[name='price_type']").click(function(){
				var price_type = $('input[name="price_type"]:checked').val();
				if (price_type == 0) {
					$("#xinsu-price-type").hide();
				} else {
					$("#xinsu-price-type").show();
					$("#bull_price").val($("#stock_price").val());
				}
			})
			
			//股票信息
			function get_stock() {
				var code = $('#stock_code').val();
				if(code.length == 6 && stock >= 0) {
					http_request_post("/stock/ajax_get_stock", {code : code}, function(result) {
						var data = result.data;
						//卖五
						$("#xinsu-stock-info").find("tr").eq(0).find("td").eq(1).html(data[29]);
						$("#xinsu-stock-info").find("tr").eq(0).find("td").eq(2).html(data[28]);
						//卖四
						$("#xinsu-stock-info").find("tr").eq(1).find("td").eq(1).html(data[27]);
						$("#xinsu-stock-info").find("tr").eq(1).find("td").eq(2).html(data[26]);
						//卖三
						$("#xinsu-stock-info").find("tr").eq(2).find("td").eq(1).html(data[25]);
						$("#xinsu-stock-info").find("tr").eq(2).find("td").eq(2).html(data[24]);
						//卖二
						$("#xinsu-stock-info").find("tr").eq(3).find("td").eq(1).html(data[23]);
						$("#xinsu-stock-info").find("tr").eq(3).find("td").eq(2).html(data[22]);
						//卖一
						$("#xinsu-stock-info").find("tr").eq(4).find("td").eq(1).html(data[21]);
						$("#xinsu-stock-info").find("tr").eq(4).find("td").eq(2).html(data[20]);
						
						//买一
						$("#xinsu-stock-info").find("tr").eq(5).find("td").eq(1).html(data[19]);
						$("#xinsu-stock-info").find("tr").eq(5).find("td").eq(2).html(data[18]);
						//买二
						$("#xinsu-stock-info").find("tr").eq(6).find("td").eq(1).html(data[17]);
						$("#xinsu-stock-info").find("tr").eq(6).find("td").eq(2).html(data[16]);
						//买三
						$("#xinsu-stock-info").find("tr").eq(7).find("td").eq(1).html(data[15]);
						$("#xinsu-stock-info").find("tr").eq(7).find("td").eq(2).html(data[14]);
						//买四
						$("#xinsu-stock-info").find("tr").eq(8).find("td").eq(1).html(data[13]);
						$("#xinsu-stock-info").find("tr").eq(8).find("td").eq(2).html(data[12]);
						//买五
						$("#xinsu-stock-info").find("tr").eq(9).find("td").eq(1).html(data[11]);
						$("#xinsu-stock-info").find("tr").eq(9).find("td").eq(2).html(data[10]);
						
						//价格
						$("#xinsu-stock-info").find("tr").eq(10).find("td").eq(1).html(data[3]);
						$("#xinsu-stock-info").find("tr").eq(10).find("td").eq(3).html(data[2]);
						//涨停
						$("#xinsu-stock-info").find("tr").eq(11).find("td").eq(1).html(data[4]);
						$("#xinsu-stock-info").find("tr").eq(11).find("td").eq(3).html(data[5]);
						
						//股票信息
						$("#stock_name").val(data[0]);
						$("#stock_price").val(data[3]);

						//可买股数
						if (Math.floor(amount / data[3]) <= 0) {
							var num = 0;
						} else {
							var num = Math.floor(amount / data[3]);
						}
						$("#num").val(num);
					})
					
					stock = setTimeout("get_stock();", 1500);
				}
			}
			
			//全部买入
			function bull_all() {
				var bull_num = $("#num").val();
				$("#bull_num").val(bull_num);
			}
		</script>
		<{/if}>
<{include file="public/footer.html"}>